export

OSE=$(OPENSSLDIR)/engines
ENGINEBASE:=$(PWD)/../stage1/engine
LIBSRC:=$(PWD)/src
SRC:=$(ENGINEBASE)/src:$(LIBSRC)
#LIBS:=libpecc-stage4.a
LIBS:=libpecc-stage4.o libpecc-stage4-embedded.o
embedobjs:=src/spu/pecc_stage4_spu
DEPLIBS:=spe2
DEPS:=$(LIBS)
LIBDEPS:=
BUILDDIR:=$(PWD)/build
TARGETTYPE:=release
VPATH:=$(VPATH):$(LIBSRC):$(BUILDDIR)
M64=-m64

#APPNAME=speed_app
#APPFLAGS=-g

%release: TARGETTYPE:=release
%debug: TARGETTYPE:=debug
#omp-%: ENGINETYPE:=engine_static
omp-%: ENGINETYPE:=app_static
omp-%: M64:=
omp-%: PATH:=$(PATH):/opt/ibmcmp/xlc/ssc/0.9/bin
gcc-omp-%: M64:=
omp-%: COMPILIER:=omp
xlc-%: COMPILIER:=xlc
gcc-%: COMPILIER:=gcc
#omp-%: OPENSSLDIR:=/home/fedora/HPC/stage1/ssc/openssl-0.9.8g
#omp-%: OPENSSLDIR:=/home/fedora/HPC/HPCProj/openmptest/src/openssl-0.9.8g
omp-%: OPENSSLDIR:=/home/fedora/HPC/stage1/ssc-good/openssl-0.9.8g
xlc-%: OPENSSLDIR:=/home/fedora/HPC/stage1/xlc/openssl-0.9.8g
gcc-%: OPENSSLDIR:=/home/fedora/HPC/stage1/gcc/openssl-0.9.8g
#gcc-%: ENGINETYPE:=app_static

all: usage

copy:
	scp $(BUILDDIR)/libpecc-stage4.so ps3:/tmp/ && scp $(BUILDDIR)/signver ps3:/tmp/


#all: omp-debug
all: gcc-debug

usage:
	@echo "Run make <xlc/gcc>-<release/debug>"	


omp-release: release
omp-debug: debug
xlc-release: release
xlc-debug: debug
gcc-release: release
gcc-debug: debug
gcc-omp-release: release
gcc-omp-debug: debug

release: $(DEPS)
	$(MAKE) -I $(PWD) -C $(ENGINEBASE) $@
	([ -n "$(EXTRADIR)" ] && $(MAKE) -C $(EXTRADIR) || false ) || true

debug: $(DEPS)
	$(MAKE) -I $(PWD) -C $(ENGINEBASE) $@
	([ -n "$(EXTRADIR)" ] && $(MAKE) -C $(EXTRADIR) || false ) || true

gcc-noengine-debug: $(DEPS)
gcc-noengine-release: $(DEPS)
gcc-noengine: gcc-noengine-debug
omp-noengine-debug: $(DEPS)
omp-noengine-release: $(DEPS)
omp-noengine: omp-noengine-debug
xlc-noengine-debug: $(DEPS)
xlc-noengine-release: $(DEPS)
xlc-noengine: xlc-noengine-debug

%-noengine-debug:	
	([ -n "$(EXTRADIR)" ] && $(MAKE) -C $(EXTRADIR) || false ) || true
%-noengine-release:	
	([ -n "$(EXTRADIR)" ] && $(MAKE) -C $(EXTRADIR) || false ) || true

$(DEPS):
	$(MAKE) -C $(LIBSRC) -f $(LIBSRC)/Makefile.lib $@

clean:
	rm -f $(BUILDDIR)/*
	$(MAKE) -C $(LIBSRC) -f $(LIBSRC)/Makefile.lib TARGETTYPE=clean $@

.PHONY: clean


